﻿namespace Tester.DL645.Responses
{
    /// <summary>
    /// 
    /// </summary>
    public class EnergyResponse: AbstractReponse
    {
        /// <summary>
        /// 
        /// </summary>
        public decimal Value { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="buffer"></param>
        public EnergyResponse(byte[] buffer) : base(buffer)
        {
            this.ResponseType = Core.ResponseType.Energy;
            
            this.Value = int.Parse(string.Join("", buffer.Skip(14)
                .Take(4)
                .Reverse()
               .Select(item => (item - 0x33).ToString("X2")))) * 0.01m;

            this.Description = string.Format("value：{0}", this.Value.ToString());
        }
    }
}
